<template>
  <el-drawer
    ref="drawerRef"
    :visible.sync="show"
    direction="ltr"
    :with-header="false"
    size="60%"
    :before-close="handleClose"
  >
    <div class="drawer-content" v-loading="loading">
      <div class="drawer-content-title">
        <span>{{ title }}</span>
        <div class="location-type-all">
          <!--管理动作 继承分数-->
          <!--<extend-score v-if="submitParams.chkitemCode == SCORE_TYPE.GLDZ" style="flex: 1;" ref="extendScoreRef" @extendScore="extendGldzScore" />-->
          <!-- 观感 空鼓开裂 甩项-->
          <el-checkbox-group v-model="locationType.group" v-if="submitParams.chkitemCode == SCORE_TYPE.ZLGG || submitParams.chkitemCode == SCORE_TYPE.ZLKGKL" size="small" style="display: inline-block">
            <el-checkbox label="hn" border @change="locationTypeChange($event, LOCATION_TYPE.HN)">户内甩项</el-checkbox>
            <el-checkbox label="gq" border @change="locationTypeChange($event, LOCATION_TYPE.GQ)">公区甩项</el-checkbox>
            <el-checkbox v-if="submitParams.chkitemCode == SCORE_TYPE.ZLGG && isConstruction" label="wlm" border @change="locationTypeChange($event, LOCATION_TYPE.WLM)">外立面甩项</el-checkbox>
          </el-checkbox-group>
          <!--管理动作 甩项-->
          <el-checkbox-group v-else-if="$route.query.chkitemCode == CHECK_TYPE_CODE.GLDZ" v-model="gldzGroup" size="small" style="display: inline-block">
            <el-checkbox label="gldz-ybys" border @change="locationTypeChange($event, SCORE_TYPE.GLDZYBYS)">样板验收甩项</el-checkbox>
            <el-checkbox label="gldz-dagl" border @change="locationTypeChange($event, SCORE_TYPE.GLDZDAGL)">档案管理甩项</el-checkbox>
            <el-checkbox label="gldz-gxys" border @change="locationTypeChange($event, SCORE_TYPE.GLDZGXYS)">关键工序验收甩项</el-checkbox>
          </el-checkbox-group>
          <el-checkbox v-else v-model="locationType.checkAll" @change="handleCheckAllChange" border size="small">全选甩项</el-checkbox>
          <el-button type="primary" @click="allExpand(false)" style="margin-left: 30px;" size="small">
            <span v-show="inspectionData.terms.length > collapseValue.length">全部展开 <i class="el-icon-arrow-right" /></span>
            <span v-show="inspectionData.terms.length <= collapseValue.length">全部折叠 <i class="el-icon-arrow-down" /></span>
          </el-button>
        </div>
      </div>
      <div class="drawer-content-data" ref="standardListTop">
        <check-area ref="checkAreaRef" @getReaList="getReaList" />
        <div class="base-terms-content">
          <el-collapse v-model="collapseValue">
            <el-collapse-item v-for="(terms, index) in inspectionData.terms" :key="'terms' + index" class="base-terms-item" :class="['checkbox-' + terms.checkboxStatus]" :name="'termsCarousel' + index">
              <div slot="title" class="check-type" v-if="terms.tableName">
                <!--{{ terms.levelType == 'base' ? index : index - inspectionData.count.base - 1 }}、{{ terms.tableName }}-->
                <span>{{ index + 1 }}、</span>
                <span v-if="submitParams.chkitemCode !== SCORE_TYPE.GLDZ && submitParams.chkitemCode !== SCORE_TYPE.ZLATSG && submitParams.chkitemCode !== SCORE_TYPE.ZLCLGL">
                  <span v-if="submitParams.chkitemCode === SCORE_TYPE.ZLSCSL" class="parent-table-name">{{ terms.parentTableName }} / {{ terms.standardList && terms.standardList[0] && terms.standardList[0].tableName }} / </span>
                  <span v-else-if="terms.parentTableName " class="parent-table-name">{{ terms.parentTableName }} / </span>
                </span>
                <span>{{ terms.tableName }}</span>
                <span v-if="submitParams.chkitemCode === SCORE_TYPE.GLDZ" style="margin-left: 10px;" :class="{ danger: gldzGroupScore[terms.tableId] < 80 }">【{{ gldzGroupScore[terms.tableId] }}分】</span>
                <el-tag v-if="terms.locationType && submitParams.chkitemCode === SCORE_TYPE.ZLGG || submitParams.chkitemCode === SCORE_TYPE.ZLKGKL" class="location-type">{{ terms.locationType | locationType }}</el-tag>
              </div>
              <div v-for="(point, indexP) in terms.standardList" :key="'point' + indexP" class="point-content" :class="{'cannot-check': point.result === -1}" :ref="point.randomString">
                <!--管理动作-样板验收-->
                <gldz-templet-check v-if="point.scoreType == SCORE_TYPE.GLDZYBYS && point.courseCode == 'ybyspj'" @getData="templetChange($event, point)" :process-type="processType" :index="indexP" :check-record-row="checkRecordRow" :standard="point" :score-type="submitParams.chkitemCode" />
                <!--test data 测试参数-->
                <div v-else>
                  <div class="point-descr">
                    <div :class="{'danger': point.itemLevel == '2' || point.itemLevel == '3', 'cannot-check-item': point.result === -1}" style="margin-right: 20px;">
                      <div v-if="submitParams.chkitemCode === SCORE_TYPE.ZLSCSL" style="color: #67C23A;margin-bottom: 10px;">评判标准：{{ point.mrqStandard }}</div>
                      <span v-if="point.itemLevel==3">*</span>
                      <span v-if="submitParams.chkitemCode === SCORE_TYPE.ZLSCSL">规则方法：{{ point.standardContent }}</span>
                      <span v-else>{{ indexP + 1 }}、{{ point.standardContent }}</span>
                      <el-tooltip effect="dark" placement="top-start">
                        <div slot="content" style="max-width: 400px;line-height: 20px;">评判规则：{{ point.ruleContent }}</div>
                        <i class="el-icon-question rule-content" />
                      </el-tooltip>
                      <el-tag v-if="point.ruleType==RULE_TYPE.HGJF && point.mixCheck && submitParams.chkitemCode!=SCORE_TYPE.ZLSCSL" style="margin-left: 20px;" type="danger">检测点要求：{{ point.mixCheck }}个</el-tag>
                    </div>
                    <!--甩项-->
                    <div class="no-check">
                      <el-checkbox v-model="point.result" :true-label="-1" :false-label="10" @change="noCheck(point)" @click.native="noCheckNative(point)">甩项</el-checkbox>
                    </div>
                  </div>
                  <!--条件条款-->
                  <div v-if="point.conditionOptions" class="operater-condition">
                    <el-radio-group v-model="point.itemSel" :disabled="point.result === -1" class="custom-radio" @input="conditionChange($event,point)">
                      <el-radio :label="condition.name" v-for="(condition, cindex) in point.conditionOptions" :key="'condition' + cindex">{{ condition.name }}</el-radio>
                    </el-radio-group>
                    <el-tag v-if="point.isStrict === 1" type="danger" size="large" class="violate-standard">严控项</el-tag>
                  </div>
                  <!--实测实量 计分不属于规则 而是 合格点 / 总检查点 * 100-->
                  <div v-if="submitParams.chkitemCode==SCORE_TYPE.ZLSCSL" class="scsl-count">
                    <el-input :disabled="point.result === -1" placeholder="请输入" v-model.number="point.checkTotal" class="input-width" @change="scslCountChange(point)">
                      <template slot="prepend">实际检查:</template>
                      <template slot="append">{{ point.ruleUnit || '处' }}</template>
                    </el-input>
                    <el-input :disabled="point.result === -1" placeholder="请输入" v-model.number="point.goodTotal" class="input-width" style="margin-left: 30px;" @change="scslCountChange(point)">
                      <template slot="prepend">合格数量:</template>
                      <template slot="append">{{ point.ruleUnit || '处' }}</template>
                    </el-input>
                    <el-tag v-if="point.isStrict === 1" type="danger" size="large" class="violate-standard">严控项</el-tag>
                  </div>
                  <!--其他 根据规则计分-->
                  <div v-else class="data-row">
                    <!--显示符合还是不符合-->
                    <div v-if="point.ruleType==RULE_TYPE.FHTK" class="operater-first">
                      <el-radio-group v-model="point.result" class="custom-radio" :disabled="point.result === -1" @input="overallEvaluation">
                        <el-radio :label="accord.value" v-for="(accord, aindex) in accordOptions" :key="'accord' + aindex">{{ accord.name }}</el-radio>
                      </el-radio-group>
                    </div>
                    <!-- 合格计分： 实际检查 与 合格数量-->
                    <div v-else-if="point.ruleType==RULE_TYPE.HGJF" class="operater-first">
                      <el-input :disabled="point.result === -1" placeholder="请输入" v-model.number="point.checkTotal" class="input-width" @change="badTotalChange(point)">
                        <template slot="prepend">实际检查:</template>
                        <template slot="append">{{ point.ruleUnit || '处' }}</template>
                      </el-input>
                      <el-input :disabled="point.result === -1" placeholder="请输入" v-model.number="point.goodTotal" class="input-width" style="margin-left: 30px;" @change="badTotalChange(point)">
                        <template slot="prepend">合格数量:</template>
                        <template slot="append">{{ point.ruleUnit || '处' }}</template>
                      </el-input>
                    </div>
                    <!--分类扣分-->
                    <category-reduce-score v-else-if="point.ruleType==10" @getCategoryData="getCategoryData($event, point)" :point="point" />
                    <!--ruleType 1,2,4,6,7,8-->
                    <div v-else class="operater-first">
                      <!--观感 户内 与 外立面-->
                      <gg-hn-wlm
                        v-if="submitParams.chkitemCode==SCORE_TYPE.ZLGG && (point.locationType == LOCATION_TYPE.HN || point.locationType == LOCATION_TYPE.WLM)"
                        :location-type="point.locationType"
                        :point="point"
                        @change="ggHnWlmChange($event, point)"
                      />
                      <el-input v-else :disabled="point.result === -1 || !point.ruleType" placeholder="请输入" v-model.number="point.badTotal" class="input-width" @change="badTotalChange(point)">
                        <template slot="prepend">违反:</template>
                        <template slot="append">{{ point.ruleUnit || '处' }}</template>
                      </el-input>
                      <div v-if="!point.ruleType" class="remain-desc">*请先配置抽检规则</div>
                    </div>
                    <!--根据阈值，判定是否违反标准-->
                    <el-tag v-if="point.isViolateStandard" type="danger" size="large" class="violate-standard">违反标准</el-tag>
                    <el-tag v-if="point.isStrict === 1" type="danger" size="large" class="violate-standard">严控项</el-tag>
                  </div>
                  <div class="vos-area-list">
                    <template v-if="point.areaList">
                      <div class="item" v-for="(areaItem, areaIndex) in point.areaList" :key="'area-item' + areaIndex" :title="areaItem.shortName">
                        <i v-if="!terms.checkboxStatus && point.result !== -1" class="el-icon-circle-close btn-del" @click="removeArea(point.areaList, areaItem, areaIndex)" />
                        <el-image class="img g-img-placeholder" :src="areaItem.url" fit="cover" :initial-index="areaIndex" :preview-src-list="point.areaList.map(i => i.url)" />
                        <div v-if="point.unitType">
                          <div class="area-name ellipsis2" v-if="point.result === -1">{{ areaItem.shortName || '暂无选择位置' }}</div>
                          <div class="area-name ellipsis2" v-else>
                            <el-checkbox class="area-checkbox" v-model="areaItem.checked" :class="{ checked: areaItem.checked }" @change="toggleCheckboxForOtherItems(index)" />
                            <span @click="selectStandardArea(point, areaItem, index, indexP, areaIndex)" :class="{ pointer: !isMultiAreas }">{{ areaItem.shortName || '选择位置' }}</span>
                          </div>
                        </div>
                      </div>
                    </template>
                    <div class="item" v-if="canSaveItems && !terms.checkboxStatus && point.result !== -1">
                      <div class="area-select-img el-upload--picture-card" @click="openSelectFileList(index, indexP)">
                        <i class="el-icon-plus" />
                      </div>
                    </div>
                  </div>
                  <div style="margin-top: 10px;">
                    <el-input
                      type="textarea"
                      show-word-limit
                      :maxlength="1000"
                      :disabled="point.result === -1"
                      :autosize="{ minRows: 2, maxRows: 4}"
                      placeholder="请输入备注"
                      v-model="point.remark"
                    />
                  </div>
                </div>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>
        <div v-if="inspectionData.terms.length == 0" class="custom-is-empty">
          <el-empty description="暂无数据。" />
        </div>
      </div>
      <div class="button-operate">
        <div class="level-desc">
          <div class="evaluation-level">
            <span v-if="submitParams.chkitemCode === SCORE_TYPE.FSL">
              <span>评价等级 : {{ inspectionData.scoreLevel }}级</span>
              <el-checkbox
                v-if="isConstruction"
                v-model="inspectionData.fslIsDlsyUnsuit"
                :true-label="1"
                :false-label="0"
                @change="dlsyUnsuitChange"
                text-color="#FF3E4C"
                class="dlsy-unsuit"
              >独立商业检查为C级</el-checkbox>
            </span>
            <span v-else-if="submitParams.chkitemCode === SCORE_TYPE.ZLATSG || submitParams.chkitemCode === SCORE_TYPE.ZLCLGL">扣除分数：【{{ inspectionData.score }} 分】</span>
            <span v-else>评价等级 : {{ inspectionData.scoreLevel }}级 【{{ inspectionData.score }} 分】</span>
            <span v-if="inspectionData.reduceScore" class="reduce-score">总倒扣分：【{{ inspectionData.reduceScore }} 分】</span>
            <!--观感 详细得分-->
            <!--<span v-if="submitParams.chkitemCode === SCORE_TYPE.ZLGG" class="detail-score">
              <span class="score-item">户内得分：<span class="score">{{ detailScore.indoor }}</span></span>
              <span class="score-item">公区得分：<span class="score">{{ detailScore.publicArea }}</span></span>
              <span v-if="isConstruction" class="score-item">外立面得分：<span class="score">{{ detailScore.outsideWall }}</span></span>
            </span>-->
            <!--空鼓开裂 详细得分-->
            <!-- <span v-if="submitParams.chkitemCode === SCORE_TYPE.ZLKGKL" class="detail-score">
              <span class="score-item">户内合格率：<span class="score">{{ detailScore.indoor }}%</span></span>
              <span class="score-item">公区合格率：<span class="score">{{ detailScore.publicArea }}%</span></span>
            </span>-->
          </div>
          <div class="evaluation-desc">*注：此评价等级分数并非最终等级</div>
        </div>
        <div>
          <el-button type="primary" size="small" @click="btnSelectStandardArea" v-if="isMultiAreas">选择位置</el-button>
          <el-button type="info" size="small" @click="$refs.drawerRef.closeDrawer()">关闭</el-button>
          <el-button type="success" size="small" @click="saveTempStorage()" v-if="canSaveItems && needTemp">暂存</el-button>
          <el-button type="primary" size="small" @click="submitEvaluation()" v-if="canSaveItems">提交</el-button>
        </div>
      </div>
    </div>
    <!--问题区域选取-->
    <SelectArea ref="SelectArea" @ok="onSelectArea" />
    <SelectFileList ref="SelectFileList" multiple @ok="onSelectFileList" />
  </el-drawer>
</template>

<script>
import { CHECK_TYPE_CODE } from '@/views/checkScore/courseCheck/baseData.js'
import { generateTaskRectifyTmpId, assignAreaPosition } from '@/utils/cq'
import { RULE_TYPE, LOCATION_TYPE, GLDZ_YBYSPJ, cqProductType } from '@/utils/baseData'
import { TJ_SCORE_TYPE, JZ_SCORE_TYPE, GLDZ_SCORE_TYPE } from '../baseData'
import store from '@/store'
import auth from '@/plugins/auth'
import { getFileURL } from '@/api/common'
import checkArea from './checkArea'
import SelectArea from './selectArea'
import SelectFileList from './SelectFileList'
// import extendScore from './extendScore'
import gldzTempletCheck from './gldzTempletCheck'
import ggHnWlm from './ggHnWlm'
import categoryReduceScore from './categoryReduceScore'
import {
  saveTempStorage,
  getTempStorage
} from '@/api/projectInspection/courseCheck'
import { cqEvalScoreItemInfo, saveItemScores } from '@/api/checkScore/courseCheck'
import evaluation from '../evaluation'
let SCORE_TYPE = {} // chkitemCode=GC-001-001

export default {
  name: 'Antiseep',
  components: { gldzTempletCheck, checkArea, SelectArea, SelectFileList, ggHnWlm, categoryReduceScore },
  filters: {
    locationType(val) {
      let name = ''
      if (val === LOCATION_TYPE.HN) {
        name = '户内'
      } else if (val === LOCATION_TYPE.GQ) {
        name = '公区'
      } else if (val === LOCATION_TYPE.WLM) {
        name = '外立面'
      }
      return name
    }
  },
  props: { processType: { type: String, default: '' } },
  data() {
    return {
      CHECK_TYPE_CODE: CHECK_TYPE_CODE,
      RULE_TYPE: RULE_TYPE,
      SCORE_TYPE: {},
      LOCATION_TYPE: LOCATION_TYPE,
      title: '土建过程-防渗漏',
      show: false,
      inspectionData: {
        scoreLevel: '', // 计算分数 显示 评估等价
        terms: [],
        count: {},
        score: '',
        ybysScore: '',
        gxysScore: '',
        daglScore: '',
        reduceScore: '',
        fslIsDlsyUnsuit: 0 // // 独立商业检查是否为C 1是 0否
      },
      detailScore: { // 观感、空鼓开裂 得分详细
        indoor: 0,
        publicArea: 0,
        outsideWall: 0
      },
      // 防渗漏评估规则配置
      antiseepRule: [
        {
          score: 'A',
          rules: [{
            maxRed: 0,
            maxRedstar: 0,
            maxBlack: 1
          }]
        },
        {
          score: 'B',
          rules: [{
            maxRed: 1,
            maxRedstar: 0,
            maxBlack: 1
          }, {
            maxRed: 0,
            maxRedstar: 0,
            maxBlack: 2
          }]
        }
      ],
      accordOptions: [
        {
          name: '符合',
          value: 10
        },
        {
          name: '不符合',
          value: 11
        }
      ],
      loading: false,
      clickObj: {},
      submitParams: {
        prjchkId: '',
        chkitemCode: '',
        versionCode: '',
        productType: '', // 业态
        cqEvalChkitemScores: [], // 多条业态主数据
        scoreItems: [],
        relationTask: '', // 继承 管理动作 Id
        score: '',
        scoreType: ''
      },
      checkRecordRow: {},
      isConstruction: true, // true 土建过程 或 false 精装
      locationType: {
        group: [],
        checkAll: false
      },
      gldzGroup: [], // 管理动作 子项
      rdcAreas: [], // 抽查区域
      // 当前条款内选中的图片，用于选完位置后(批量)赋值。list: { stdIndex: number, areaIndex: number, area: object }[]
      currTermAreas: { termIndex: 0, unitType: '', list: [] },
      // 当前标准位置，用于选完图片后赋值
      currStandard: { termIndex: 0, stdIndex: 0 },
      // 批量选位置模式
      isMultiAreas: false,
      inherit: {
        gxysScore: 100,
        ybysScore: 100,
        daglScore: 100,
        gldzScore: 100
      },
      needTemp: true,
      tmpId: '',
      collapseValue: []
    }
  },
  computed: {
    canSaveItems() {
      // 有权保存
      const userFid = store.getters.user?.fid
      const roles = store.getters.roles || []
      const { processType, checkRecordRow } = this

      // 用户含抽检角色时，需为本项目指定的抽检人员才有权限
      if (roles.includes('GCCJRY')) return checkRecordRow.principalId === userFid

      // 不含抽检角色，有保存权限时，需为有授权的项目（项目列表即展示有授权的，这里不需判断）
      return auth.hasPermi(`cq:${processType}:saveItems`)
    },
    gldzGroupScore() {
      const obj = {}
      obj[SCORE_TYPE.GLDZYBYS] = this.inspectionData.ybysScore
      obj[SCORE_TYPE.GLDZGXYS] = this.inspectionData.gxysScore
      obj[SCORE_TYPE.GLDZDAGL] = this.inspectionData.daglScore
      return obj
    }
  },
  created() { // 初始化
    if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.TJGC) { // 土建过程
      SCORE_TYPE = { ...TJ_SCORE_TYPE}
      this.SCORE_TYPE = { ...TJ_SCORE_TYPE}
      this.isConstruction = true
    } else if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.JZGC) { // 精装
      SCORE_TYPE = { ...JZ_SCORE_TYPE}
      this.SCORE_TYPE = { ...JZ_SCORE_TYPE}
      this.isConstruction = false
    } else if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
      SCORE_TYPE = { ...GLDZ_SCORE_TYPE }
      this.SCORE_TYPE = { ...GLDZ_SCORE_TYPE }
      this.isConstruction = false
    }
  },
  methods: {
    dlsyUnsuitChange (val) {
      console.log(val)
      this.overallEvaluation()
    },
    allExpand(expand = false) {
      if (expand) {
        this.collapseValue = []
        for (let i = 0; i < this.inspectionData.terms.length; i++) {
          this.collapseValue.push('termsCarousel' + i)
        }
      } else {
        if (this.collapseValue.length >= this.inspectionData.terms.length) {
          this.collapseValue = []
        } else {
          for (let i = 0; i < this.inspectionData.terms.length; i++) {
            this.collapseValue.push('termsCarousel' + i)
          }
        }
      }
    },
    saveTempStorage() {
      this.inspectionData.collapseValue = this.collapseValue
      const params = {
        tmpId: this.tmpId,
        taskId: this.submitParams.prjchkId,
        scoreType: this.submitParams.chkitemCode,
        productType: this.submitParams.productType,
        tmpJson: JSON.stringify(this.inspectionData)
      }
      if (!params.productType) {
        delete params.productType
      }
      if (this.loading) return
      this.loading = true
      saveTempStorage(params).then(response => {
        if (response.code === 200) {
          this.msgSuccess('抽检结果暂存成功。')
        }
      }).finally(() => {
        this.loading = false
      })
    },
    getTempStorage() {
      const params = {
        taskId: this.submitParams.prjchkId,
        scoreType: this.submitParams.chkitemCode,
        productType: this.submitParams.productType
      }
      this.loading = true
      getTempStorage(params).then(response => {
        if (response.code === 200) {
          try {
            if (response.data && response.data.length > 0) {
              this.inspectionData = JSON.parse(response.data[0].tmpJson)
              this.collapseValue = this.inspectionData.collapseValue || []
              this.tmpId = response.data[0].tmpId
              this.locationType.checkAll = evaluation.allNoCheck(this.inspectionData.terms)
              this.getNoCheckItem()
            }
          } catch (e) {
            console.log(e)
          }
        }
      }).finally(() => {
        this.loading = false
      })
    },
    ggHnWlmChange(obj, point) {
      point.deductJson = JSON.stringify(obj.form)
      point.score = obj.score
      point.badTotal = obj.badTotal
      point.result = obj.result
      this.overallEvaluation()
    },
    //  管理动作 继承
    extendGldzScore(row) {
      this.submitParams.relationTask = row.fid
      if (row && row.gldzScore) {
        this.inspectionData.score = row.gldzScore
        this.inherit.gldzScore = parseFloat(row.gldzScore) || 100
        this.inherit.gxysScore = parseFloat(row.gxysScore) || 100
        this.inherit.ybysScore = parseFloat(row.ybysScore) || 100
        this.inherit.daglScore = parseFloat(row.daglScore) || 100
      } else {
        this.inherit = {
          gxysScore: 100,
          ybysScore: 100,
          daglScore: 100,
          gldzScore: 100
        }
      }
      this.overallEvaluation()
    },
    templetChange({score, result, options}, point) {
      point.score = score
      point.result = result
      if (point.children.every(item => !item.result)) {
        point.badTotal = null
      } else {
        point.badTotal = 0 // 检查必填项使用
      }
      if (options) {
        point.children.forEach(item => {
          if (item.courseId === options.courseId) {
            item.scoreItemId = options.scoreItemId
          }
        })
      }
      this.overallEvaluation()
    },
    // 批量设置位置
    btnSelectStandardArea() {
      const { termIndex } = this.currTermAreas
      const standardList = this.inspectionData.terms[termIndex].standardList
      let firstStd = null
      let firstArea = null

      const list = []
      standardList.map((std, stdIndex) => {
        std.areaList.map((area, areaIndex) => {
          if (area.checked) {
            list.push({ stdIndex, areaIndex, area })
            if (firstArea) return
            firstStd = std
            firstArea = area
          }
        })
      })

      this.currTermAreas = { termIndex, unitType: firstStd.unitType, list }
      this.resetAllCheckbox()

      this.$refs.SelectArea.open({
        rdcScore: this.checkRecordRow,
        rdcAreas: this.rdcAreas,
        currArea: firstArea,
        scoreType: this.submitParams.chkitemCode,
        unitType: firstStd.unitType,
        isFirezone: firstStd.isFirezone
      })
    },
    // 选取位置(用于单个)
    selectStandardArea(point, area, termIndex, stdIndex, areaIndex) {
      if (this.isMultiAreas) return
      if (point.result === -1) return this.$message.info('甩项不能操作')

      const list = [{ stdIndex, areaIndex, area }]
      this.currTermAreas = { termIndex, unitType: point.unitType, list }
      this.resetAllCheckbox()

      this.$refs.SelectArea.open({
        rdcScore: this.checkRecordRow,
        rdcAreas: this.rdcAreas,
        currArea: area,
        scoreType: this.submitParams.chkitemCode,
        unitType: point.unitType,
        isFirezone: point.isFirezone
      })
    },
    // 条件条款 切换
    conditionChange(name, point) {
      point.itemLevel = point.standardLevel
      const conditionOptions = point.conditionOptions
      for (let j = 0; j < conditionOptions.length; j++) {
        if (conditionOptions[j].name === name) {
          point.ruleJson = conditionOptions[j].ruleJson
          point.ruleType = conditionOptions[j].ruleType
          point.ruleUnit = conditionOptions[j].ruleUnit
        }
      }
      if (point.ruleType !== RULE_TYPE.HGTK) {
        point.isViolateStandard = false
      }
      this.badTotalChange(point)
    },
    // 全局甩项变化
    handleCheckAllChange(val) {
      const terms = this.inspectionData.terms
      if (val) { // 全部甩项
        for (let i = 0; i < terms.length; i++) {
          for (let j = 0; j < terms[i].standardList.length; j++) {
            if (terms[i].standardList[j].result !== -1) {
              terms[i].standardList[j].originalResult = terms[i].standardList[j].result
            }
            terms[i].standardList[j].result = -1
            // this.noCheckReset(terms[i].standardList[j])
          }
        }
      } else {
        for (let i = 0; i < terms.length; i++) {
          for (let j = 0; j < terms[i].standardList.length; j++) {
            if (terms[i].standardList[j].originalResult !== -1) {
              terms[i].standardList[j].result = terms[i].standardList[j].originalResult
            } else {
              terms[i].standardList[j].result = 0
            }
          }
        }
      }
      this.overallEvaluation()
    },
    // 甩项模块变化
    locationTypeChange(val, type) {
      const terms = this.inspectionData.terms
      for (let i = 0; i < terms.length; i++) {
        for (let j = 0; j < terms[i].standardList.length; j++) {
          let slType = ''
          if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
            slType = 'scoreType'
            if (type === SCORE_TYPE.GLDZYBYS && terms[i].standardList[j].courseCode === 'ybyspj') { // 样板验收 子集设置
              terms[i].standardList[j].children.forEach(item => {
                if (val) {
                  if (item.result && item.result !== -1) {
                    item.originalResult = item.result // 甩项前 结果备份
                  }
                  item.result = -1
                } else {
                  if (item.originalResult === -1) {
                    item.result = 0
                  } else {
                    item.result = item.originalResult
                  }
                }
              })
            }
          } else { // 观感 空鼓开裂
            slType = 'locationType'
          }
          if (terms[i].standardList[j][slType] === type) {
            if (val) {
              if (terms[i].standardList[j].result && terms[i].standardList[j].result !== -1) {
                terms[i].standardList[j].originalResult = terms[i].standardList[j].result // 甩项前 结果备份
              }
              terms[i].standardList[j].result = -1
            } else {
              if (terms[i].standardList[j].originalResult === -1) {
                terms[i].standardList[j].result = 0
              } else {
                terms[i].standardList[j].result = terms[i].standardList[j].originalResult
              }
            }
          }
          // this.noCheckReset(terms[i].standardList[j])
        }
      }
      this.overallEvaluation()
    },
    // 在甩项 result值 改变前调用 保存到 originalResult
    noCheckNative(point) {
      if (point.result !== -1) {
        point.originalResult = point.result
      }
    },
    noCheck(point) { // 无法检查
      /* if (point.badTotal) {
        point.badTotal = null
      }
      if (point.goodTotal || point.checkTotal) {
        point.goodTotal = null
        point.checkTotal = null
      }
      point.isViolateStandard = false*/
      // point.fileIds = ''
      // point.files = []
      // this.noCheckReset(point)
      // this.initStandardScore(point)
      if (point.result !== -1) { // 非甩项恢复
        point.result = point.originalResult
      }
      this.overallEvaluation()
    },
    // 甩项 重置数据
    noCheckReset(point) {
      if (point.result === -1) {
        point.badTotal = null
        point.goodTotal = null
        point.checkTotal = null
        point.deductJson = null
        point.typeJson = null
        point.isViolateStandard = false
        point.score = null
      }
    },
    /*
    *  初始化
    * */

    init(row, obj) {
      console.log('-------------', obj)
      this.clickObj = obj
      Object.assign(this.detailScore, {
        indoor: 0,
        publicArea: 0,
        outsideWall: 0
      })
      // 初始化 全部收缩
      this.collapseValue = []
      this.inspectionData.scoreLevel = ''
      this.inspectionData.reduceScore = ''
      this.inspectionData.fslIsDlsyUnsuit = 0
      if (this.submitParams.cqRdcZlScoreVO) {
        this.submitParams.cqRdcZlScoreVO = null
      }
      this.tmpId = ''
      this.locationType = {
        group: [],
        checkAll: false
      }
      this.inherit = {
        gxysScore: 100,
        ybysScore: 100,
        daglScore: 100,
        gldzScore: 100
      }
      this.locationType.checkAll = false
      this.checkRecordRow = row
      this.submitParams.prjchkId = row.prjchkId
      this.submitParams.versionCode = row.versionCode
      this.submitParams.chkitemCode = obj.chkitemCode
      this.submitParams.relationTask = row.relationTask
      if (Array.isArray(obj.list)) {
        this.submitParams.cqEvalChkitemScores = obj.list
      } else {
        this.submitParams.cqEvalChkitemScores = [obj]
      }
      this.submitParams.productType = obj.productType
      this.title = `${row.chkitemName} - ${obj.chkitemName}`
      if (obj.productType) {
        for (let i = 0; i < cqProductType.length; i++) {
          if (cqProductType[i].value === obj.productType) {
            this.title += `- ${cqProductType[i].label}`
          }
        }
      }
      const params = {
        versionCode: row.versionCode,
        checkitemCode: obj.chkitemCode,
        prjchkId: row.prjchkId,
        productType: obj.productType
      }
      if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
        params.gldzLevel = '3'
      }

      this.currTermAreas = { termIndex: 0, unitType: '', list: [] }
      this.currStandard = { termIndex: 0, stdIndex: 0 }
      this.isMultiAreas = false

      this.loading = true
      cqEvalScoreItemInfo(params).then(
        response => {
          if (response.code === 200) {
            this.inspectionData.fslIsDlsyUnsuit = response.data.fslIsDlsyUnsuit || 0
            if (response.data.itemVOS && response.data.itemVOS.length > 0) { // 暂存判断
              if (!response.data.itemVOS[0].scoreItemId) {
                this.needTemp = true
                this.getTempStorage()
              } else {
                this.needTemp = false
              }
            }
            this.rdcAreas = response.data.cqRdcAreas || []
            this.$refs.checkAreaRef.init(response.data.cqRdcAreas)
            const fileItems = response.data.fileItems || []
            const itemVOS = response.data.itemVOS
            for (let i = 0; i < itemVOS.length; i++) {
              itemVOS[i].isViolateStandard = false
              itemVOS[i].checkItemCode = response.data.checkItemCode
              if (!itemVOS[i].result || itemVOS[i].result === -1) {
                itemVOS[i].originalResult = 0 // 将原结果备份
              } else {
                itemVOS[i].originalResult = itemVOS[i].result
              }
              if (!itemVOS[i].itemLevel) {
                itemVOS[i].itemLevel = itemVOS[i].standardLevel
              }
              if (itemVOS[i].ruleType !== 1) {
                itemVOS[i].itemLevel = itemVOS[i].standardLevel
              }
              itemVOS[i].randomString = getRandomString(20)
              if (itemVOS[i].badTotal) {
                itemVOS[i].badTotal = Number(itemVOS[i].badTotal)
              }
              if (itemVOS[i].checkTotal) {
                itemVOS[i].checkTotal = Number(itemVOS[i].checkTotal)
              }
              if (itemVOS[i].goodTotal) {
                itemVOS[i].goodTotal = Number(itemVOS[i].goodTotal)
              }
              if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) { // 增加 管理动作 类型名称
                if (this.submitParams.chkitemCode === SCORE_TYPE.GLDZGXYS) {
                  itemVOS[i].gldzTypeName = '关键工序验收'
                } else if (this.submitParams.chkitemCode === SCORE_TYPE.GLDZDAGL) {
                  itemVOS[i].gldzTypeName = '档案管理'
                } else if (this.submitParams.chkitemCode === SCORE_TYPE.GLDZYBYS) {
                  itemVOS[i].gldzTypeName = '样板验收'
                }
              }
              // 观感 初始化数据
              /* if (this.submitParams.chkitemCode === SCORE_TYPE.ZLGG && (itemVOS[i].locationType === LOCATION_TYPE.HN || itemVOS[i].locationType === LOCATION_TYPE.WLM)) {
                if (!itemVOS[i].score) {
                  itemVOS[i].badTotal = 0
                }
              }*/

              // 获取区域数据
              const standardId = itemVOS[i].standardId
              const mrqId = itemVOS[i].mrqId
              const areaList = fileItems.filter(r => r.standardId === standardId && r.mrqId === mrqId)
              areaList.map(area => {
                // checked 初始化
                area.checked = false
                area.url = getFileURL(area.fileId)
                // 注：rectifyId 现用于判断从历史添加，此处暂不需要
                delete area.rectifyId
              })
              itemVOS[i].areaList = areaList
              // 备份，用于保存时，对比删除了哪些位置
              itemVOS[i].areaListBackUp = JSON.parse(JSON.stringify(areaList))

              // 违反扣分 设置 最小检测 数量
              if (itemVOS[i].ruleType === RULE_TYPE.HGJF) {
                let ruleJson = []
                if (itemVOS[i].ruleJson) {
                  try {
                    ruleJson = JSON.parse(itemVOS[i].ruleJson)
                  } catch (e) {
                    console.log(e)
                  }
                }
                if (ruleJson.length > 0 && ruleJson[0].total) {
                  itemVOS[i].mixCheck = ruleJson[0].total
                }
              }
              if (itemVOS[i].ruleType === RULE_TYPE.TJTK) { // 条件条款
                let conditionOptions = []
                try {
                  conditionOptions = JSON.parse(itemVOS[i].ruleJson)
                } catch (e) {
                  console.log(e)
                }
                itemVOS[i].conditionOptions = conditionOptions
                // 默认第一个条件条款
                if (!itemVOS[i].itemSel) {
                  itemVOS[i].itemSel = conditionOptions[0].name
                }
                for (let j = 0; j < conditionOptions.length; j++) {
                  if (conditionOptions[j].name === itemVOS[i].itemSel) {
                    itemVOS[i].ruleJson = conditionOptions[j].ruleJson
                    itemVOS[i].ruleType = conditionOptions[j].ruleType
                    itemVOS[i].ruleUnit = conditionOptions[j].ruleUnit
                  }
                }
              }
              const arrCode = ['ybyspj', 'tjlchy', 'jzjfybys', 'jzgfybys', 'fslzxyb', 'jfybys'] // 样板验收相关项
              if (!arrCode.some(code => code === itemVOS[i].courseCode)) { // 样板验收评价 相关6项 特殊规则判断
                this.initStandardScore(itemVOS[i])
              }
            }
            this.inspectionData.terms = this.getStandardFormat(itemVOS).list
            this.inspectionData.score = obj.scoreInput
            this.inspectionData.scoreLevel = obj.scoreLevel
            this.inspectionData.reduceScore = obj.subScore
            if (response.data.reduceScore) { // 总倒扣分
              this.inspectionData.reduceScore = response.data.reduceScore
            }
            this.locationType.checkAll = evaluation.allNoCheck(this.inspectionData.terms)
            this.getNoCheckItem()
            // this.inspectionData.count = this.getStandardFormat(itemVOS).count
            if (this.inspectionData.score && this.submitParams.chkitemCode !== SCORE_TYPE.FSL) {
              const scoreLevel = this.submitParams.chkitemCode + 'Level'
              if (this.checkRecordRow[scoreLevel]) {
                this.inspectionData.scoreLevel = this.checkRecordRow[scoreLevel]
              } else if (this.inspectionData.score >= 90) {
                this.inspectionData.scoreLevel = 'A'
              } else if (this.inspectionData.score >= 80) {
                this.inspectionData.scoreLevel = 'B'
              } else {
                this.inspectionData.scoreLevel = 'C'
              }
              if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
                if (response.data.gxysScore < 80 || response.data.ybysScore < 80) {
                  this.inspectionData.scoreLevel = 'C'
                }
              }
            }
          }
        }
      ).finally(() => {
        this.loading = false
      })
      function getRandomString(len) {
        const charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789'
        const strLength = charStr.length
        let randomStr = ''
        for (let i = 0; i < len; i++) {
          const index = Math.floor(Math.random() * strLength)
          randomStr += charStr[index]
        }
        return randomStr
      }
    },
    // 获取甩项
    getNoCheckItem() {
      let obj = {}
      const terms = this.inspectionData.terms.filter(term => term.type !== 'title')
      if (this.submitParams.chkitemCode === SCORE_TYPE.ZLKGKL) {
        const params = { isConstruction: this.isConstruction }
        obj = evaluation.calculateKgklScore(terms, params)
        if (obj.noCheck.publicArea) {
          if (!this.locationType.group.some(type => type === LOCATION_TYPE.GQ)) {
            this.locationType.group.push(LOCATION_TYPE.GQ)
          }
        } else {
          const index = this.locationType.group.findIndex(type => type === LOCATION_TYPE.GQ)
          if (index > -1) {
            this.locationType.group.splice(index, 1)
          }
        }
        if (obj.noCheck.indoor) {
          if (!this.locationType.group.some(type => type === LOCATION_TYPE.HN)) {
            this.locationType.group.push(LOCATION_TYPE.HN)
          }
        } else {
          const index = this.locationType.group.findIndex(type => type === LOCATION_TYPE.HN)
          if (index > -1) {
            this.locationType.group.splice(index, 1)
          }
        }
      } else if (this.submitParams.chkitemCode === SCORE_TYPE.ZLGG) {
        const params = { isConstruction: this.isConstruction }
        obj = evaluation.calculateGgScore(terms, params)
        if (obj.noCheck.publicArea) {
          if (!this.locationType.group.some(type => type === LOCATION_TYPE.GQ)) {
            this.locationType.group.push(LOCATION_TYPE.GQ)
          }
        } else {
          const index = this.locationType.group.findIndex(type => type === LOCATION_TYPE.GQ)
          if (index > -1) {
            this.locationType.group.splice(index, 1)
          }
        }
        if (obj.noCheck.indoor) {
          if (!this.locationType.group.some(type => type === LOCATION_TYPE.HN)) {
            this.locationType.group.push(LOCATION_TYPE.HN)
          }
        } else {
          const index = this.locationType.group.findIndex(type => type === LOCATION_TYPE.HN)
          if (index > -1) {
            this.locationType.group.splice(index, 1)
          }
        }
        if (obj.noCheck.outsideWall) {
          if (!this.locationType.group.some(type => type === LOCATION_TYPE.WLM)) {
            this.locationType.group.push(LOCATION_TYPE.WLM)
          }
        } else {
          const index = this.locationType.group.findIndex(type => type === LOCATION_TYPE.WLM)
          if (index > -1) {
            this.locationType.group.splice(index, 1)
          }
        }
      } else if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
        obj = evaluation.calculateGldzAllScore(terms, this.inherit)
        this.inspectionData.gxysScore = obj.gxysScore
        this.inspectionData.ybysScore = obj.ybysScore
        this.inspectionData.daglScore = obj.daglScore
        if (obj.noCheck.gxys) {
          if (!this.gldzGroup.some(type => type === SCORE_TYPE.GLDZGXYS)) {
            this.gldzGroup.push(SCORE_TYPE.GLDZGXYS)
          }
        } else {
          const index = this.gldzGroup.findIndex(type => type === SCORE_TYPE.GLDZGXYS)
          if (index > -1) {
            this.gldzGroup.splice(index, 1)
          }
        }
        if (obj.noCheck.ybys) {
          if (!this.gldzGroup.some(type => type === SCORE_TYPE.GLDZYBYS)) {
            this.gldzGroup.push(SCORE_TYPE.GLDZYBYS)
          }
        } else {
          const index = this.gldzGroup.findIndex(type => type === SCORE_TYPE.GLDZYBYS)
          if (index > -1) {
            this.gldzGroup.splice(index, 1)
          }
        }
        if (obj.noCheck.dagl) {
          if (!this.gldzGroup.some(type => type === SCORE_TYPE.GLDZDAGL)) {
            this.gldzGroup.push(SCORE_TYPE.GLDZDAGL)
          }
        } else {
          const index = this.gldzGroup.findIndex(type => type === SCORE_TYPE.GLDZDAGL)
          if (index > -1) {
            this.gldzGroup.splice(index, 1)
          }
        }
      }
    },
    // 初始化重新设置标准扣分 score (适用于规则改变)
    initStandardScore(data) {
      if (data.result === -1 || (this.submitParams.chkitemCode === SCORE_TYPE.ZLGG && (data.locationType === LOCATION_TYPE.HN || data.locationType === LOCATION_TYPE.WLM))) return
      let ruleJson = []
      if (data.ruleJson) {
        try {
          ruleJson = JSON.parse(data.ruleJson)
        } catch (e) {
          console.log('initStandardScore', e)
        }
        if (ruleJson && ruleJson instanceof Array && ruleJson.length > 0) {
          if (data.ruleType === RULE_TYPE.SJTK) { // 升级条款
            evaluation.upgradeTerms(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.HGTK) { // 合格条款 违反标准 (超过最小阈值)
            evaluation.violateStandard(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.ZJPD) { // 直接评定
            evaluation.directGrade(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.HGJF) { // 合格计分（违反扣分） goodTotal 与 checkTotal
            evaluation.qualifiedScore(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.YZKF) { // 阈值扣分 （阈值范围，扣分）
            evaluation.rangeReduceScore(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.CFKF) { // 重复扣分 （（badTotal - min) * score），扣分）
            evaluation.repetiteReduceScore(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.ZJKF) { // 直接扣分 （超过阈值 扣相同分）
            evaluation.directReduceScore(data, ruleJson)
          } else if (data.ruleType === RULE_TYPE.ALKF) { // 按类扣分 （（badTotal - min) * score），badTotal类别数量）
            evaluation.categoryReduceScore(data, ruleJson)
          }
        }
      }
    },
    getStandardFormat(list) {
      const inspction = {
        baseTerms: [],
        impTerms: []
      }
      // for (let i = 0; i < list.length; i++) {
      //   if (list[i].itemLevel === '3') { // 红色带星  底线条款
      //     inspction.baseTerms.push(list[i])
      //   } else { // 重要条款
      //     inspction.impTerms.push(list[i])
      //   }
      // }
      if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
        const obj = getYbysData(list)
        list = obj.otherList
        list.unshift(obj.ybys)
      }
      function getYbysData(list) {
        // 样板验收评价 相关编码
        const arrCode = [GLDZ_YBYSPJ.YBYSPJ, GLDZ_YBYSPJ.TJLCHY, GLDZ_YBYSPJ.JZJFYBYS, GLDZ_YBYSPJ.JZGFYBYS, GLDZ_YBYSPJ.FSLZXYB, GLDZ_YBYSPJ.JFYBYS]
        const otherList = list.filter(item => !arrCode.some(code => code === item.courseCode))
        const ybysList = list.filter(item => arrCode.some(code => code === item.courseCode))
        const ybys = {children: []}
        for (let i = 0; i < ybysList.length; i++) {
          if (ybysList[i].courseCode === GLDZ_YBYSPJ.YBYSPJ) { // 样板验收评价5
            Object.assign(ybys, ybysList[i])
          } else {
            switch (ybysList[i].courseCode) {
              case GLDZ_YBYSPJ.TJLCHY: // 土建楼层会验
                ybysList[i].sort = 1
                ybysList[i].isLeaf = false
                break
              case GLDZ_YBYSPJ.JZJFYBYS: // 精装交付样板验收
                ybysList[i].sort = 2
                ybysList[i].isLeaf = false
                break
              case GLDZ_YBYSPJ.JZGFYBYS: // 精装工法样板验收
                ybysList[i].sort = 3
                ybysList[i].isLeaf = true
                break
              case GLDZ_YBYSPJ.FSLZXYB: // 防渗漏专项样板
                ybysList[i].sort = 4
                ybysList[i].isLeaf = true
                break
              case GLDZ_YBYSPJ.JFYBYS: // 景观样板验收
                ybysList[i].sort = 5
                ybysList[i].isLeaf = true
                break
            }
            ybys.children.push(ybysList[i])
          }
        }
        ybys.children.sort((obj1, obj2) => {
          return obj1.sort - obj2.sort
        })
        return {otherList, ybys}
      }
      // 无需区分底线与重要 条款
      inspction.baseTerms = list
      // 根据不同字段 分类
      let categoryKey = ''
      let categoryName = ''
      if (this.submitParams.chkitemCode === SCORE_TYPE.ZLSCSL) { // 实测实量
        categoryKey = 'mrqId'
        categoryName = 'mrqName'
      } else if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) { // 管理动作
        categoryKey = 'scoreType'
        categoryName = 'gldzTypeName'
      } else if (this.submitParams.chkitemCode === SCORE_TYPE.ZLATSG || this.submitParams.chkitemCode === SCORE_TYPE.ZLCLGL) { // 按图施工 材料管理
        categoryKey = 'courseCode'
        categoryName = 'couseName'
      } else {
        categoryKey = 'tableId'
        categoryName = 'tableName'
      }
      // 针对键 tableId  底线条款 进行归类的容器
      const baseContainer = { notTableId: [] }
      inspction.baseTerms.forEach(item => {
        if (item[categoryKey]) {
          baseContainer[item[categoryKey]] = baseContainer[item[categoryKey]] || []
          baseContainer[item[categoryKey]].push(item)
        } else {
          baseContainer.notTableId.push(item)
        }
      })
      const baseTerms = []
      for (const key in baseContainer) {
        if (baseContainer[key].length > 0) {
          baseContainer[key].sort((obj1, obj2) => obj1.seq - obj2.seq)
          let parentTableSeq = baseContainer[key][0].parentTableSeq
          let parentTableCode = baseContainer[key][0].parentTableCode
          if (!parentTableSeq && parentTableSeq !== 0) {
            parentTableSeq = -1
          }
          if (!parentTableCode && parentTableCode !== '0') {
            parentTableCode = '-1'
          }
          baseTerms.push({
            // 复选框状态。空字符串-不显示，show-显示，disabled-禁用
            checkboxStatus: '',
            tableId: key,
            levelType: 'base',
            locationType: baseContainer[key][0].locationType,
            parentTableName: baseContainer[key][0].parentTableName,
            standardId: baseContainer[key][0].standardId, // 实测实量排序使用
            tableSeq: baseContainer[key][0].tableSeq,
            tableCode: baseContainer[key][0].tableCode,
            parentTableSeq: parentTableSeq,
            parentTableCode: parentTableCode,
            tableName: baseContainer[key][0][categoryName],
            standardList: baseContainer[key]
          })
        }
      }
      // console.log(baseTerms)
      // test data
      // baseTerms[0].locationType = LOCATION_TYPE.HN
      // baseTerms[0].standardList[0].locationType = LOCATION_TYPE.HN
      // baseTerms[0].standardList[1].locationType = LOCATION_TYPE.WLM
      // baseTerms[0].standardList[2].locationType = LOCATION_TYPE.GQ
      // baseTerms[0].standardList[3].locationType = LOCATION_TYPE.GQ

      // 排序
      if (this.submitParams.chkitemCode === SCORE_TYPE.ZLGG || this.submitParams.chkitemCode === SCORE_TYPE.ZLKGKL) {
        // 按 locationType 、tableSeq(tableCode) 两个字段排序
        baseTerms.sort((obj1, obj2) => {
          if (obj1.locationType === obj2.locationType) {
            if (obj2.parentTableSeq === obj1.parentTableSeq) {
              if (obj1.parentTableCode === obj2.parentTableCode) {
                if (obj2.tableSeq === obj1.tableSeq) {
                  return obj1.tableCode.localeCompare(obj2.tableCode)
                }
                return obj2.tableSeq - obj1.tableSeq
              }
              return obj1.parentTableCode.localeCompare(obj2.parentTableCode)
            }
            return obj2.parentTableSeq - obj1.parentTableSeq
          } else {
            if (obj1.locationType > obj2.locationType) {
              return 1
            } else {
              return -1
            }
          }
        })
        // for (let i = 0; i < baseTerms.length; i++) {
        //   console.log(i, baseTerms[i].locationType, baseTerms[i].parentTableSeq, baseTerms[i].parentTableCode, baseTerms[i].tableSeq, baseTerms[i].tableCode)
        // }
      } else {
        // 按 tableSeq、tableCode 字段排序
        baseTerms.sort((obj1, obj2) => {
          if (obj2.parentTableSeq === obj1.parentTableSeq) {
            if (obj1.parentTableCode === obj2.parentTableCode) {
              if (obj2.tableSeq === obj1.tableSeq) {
                if (this.submitParams.chkitemCode === SCORE_TYPE.ZLSCSL && obj1.tableCode === obj2.tableCode) {
                  return obj1.standardId.localeCompare(obj2.standardId)
                }
                return obj1.tableCode.localeCompare(obj2.tableCode)
              }
              return obj2.tableSeq - obj1.tableSeq
            }
            return obj1.parentTableCode.localeCompare(obj2.parentTableCode)
          }
          return obj2.parentTableSeq - obj1.parentTableSeq
        })

        // for (let i = 0; i < baseTerms.length; i++) {
        //   console.log(i, baseTerms[i].parentTableSeq, baseTerms[i].parentTableCode, baseTerms[i].tableSeq, baseTerms[i].tableCode, baseTerms[i].parentTableName, baseTerms[i].tableName)
        // }
      }
      // 针对键 tableId  重要条款 进行归类的容器
      /* const impContainer = { notTableId: [] }
      inspction.impTerms.forEach(item => {
        if (item[categoryKey]) {
          impContainer[item[categoryKey]] = impContainer[item[categoryKey]] || []
          impContainer[item[categoryKey]].push(item)
        } else {
          impContainer.notTableId.push(item)
        }
      })
      const impTerms = []
      for (const key in impContainer) {
        if (impContainer[key].length > 0) {
          impTerms.push({
            tableId: key,
            levelType: 'imp',
            tableName: impContainer[key][0][categoryName],
            standardList: impContainer[key]
          })
        }
      }
      const titleObj = [{ type: 'title', levelType: 'base', name: '底线条款' }, { type: 'title', levelType: 'imp', name: '重要条款' }]
      const terms = {
        count: { base: baseTerms.length, imp: impTerms.length },
        list: [titleObj[0], ...baseTerms, titleObj[1], ...impTerms] }*/
      const terms = {
        count: { base: baseTerms.length, imp: 0 },
        list: baseTerms
      }
      if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
        terms.ybys = getYbysData(list).ybys
      }
      return terms
    },
    /*
    *  获取区域数据
    * */
    getReaList(list) {
      this.inspectionData.area = list
    },
    // 提交数据
    submitEvaluation() {
      if (this.loading) return
      const rdcScore = this.checkRecordRow
      const projectId = rdcScore.projectId
      for (let i = 0; i < this.inspectionData.terms.length; i++) { // 判断所有标准 是否 检查
        for (let j = 0; j < this.inspectionData.terms[i].standardList.length; j++) {
          if (this.inspectionData.terms[i].standardList[j].result === -1) continue // 无法检查
          const ref = this.inspectionData.terms[i].standardList[j].randomString
          // 管理动作 样板验收评价 必填
          if (this.inspectionData.terms[i].standardList[j].scoreType === SCORE_TYPE.GLDZYBYS && this.inspectionData.terms[i].standardList[j].courseCode === 'ybyspj') {
            if (this.inspectionData.terms[i].standardList[j].children.some(standard => !standard.result || standard.score === '')) {
              this.controlScroll(ref, '请完善《样板验收评价》相关数据或者甩项。')
              return false
            }
          }
          if (this.submitParams.chkitemCode === SCORE_TYPE.ZLSCSL) { // 实测实量
            if (!this.inspectionData.terms[i].standardList[j].checkTotal && this.inspectionData.terms[i].standardList[j].checkTotal !== 0 ||
              !this.inspectionData.terms[i].standardList[j].goodTotal && this.inspectionData.terms[i].standardList[j].goodTotal !== 0) {
              this.controlScroll(ref)
              return false
            }
          } else if (this.inspectionData.terms[i].standardList[j].ruleType) {
            if (this.inspectionData.terms[i].standardList[j].ruleType === RULE_TYPE.FHTK) { // 符合条款
              if (![-1, 10, 11].includes(this.inspectionData.terms[i].standardList[j].result)) {
                this.controlScroll(ref)
                return false
              }
            } else if (this.inspectionData.terms[i].standardList[j].ruleType === RULE_TYPE.HGJF) { // 违反扣分
              if (!this.inspectionData.terms[i].standardList[j].checkTotal && this.inspectionData.terms[i].standardList[j].checkTotal !== 0 ||
                !this.inspectionData.terms[i].standardList[j].goodTotal && this.inspectionData.terms[i].standardList[j].goodTotal !== 0) {
                this.controlScroll(ref)
                return false
              }
            } else {
              if (!this.inspectionData.terms[i].standardList[j].badTotal && this.inspectionData.terms[i].standardList[j].badTotal !== 0) {
                this.controlScroll(ref)
                return false
              }
            }
          }
        }
      }
      if (this.submitParams.cqEvalChkitemScores.length === 1) {
        this.submitParams.cqEvalChkitemScores[0].scoreInput = this.inspectionData.score || ''
        this.submitParams.cqEvalChkitemScores[0].scoreLevel = this.inspectionData.scoreLevel || ''
        if (this.submitParams.chkitemCode === SCORE_TYPE.FSL) {
          this.submitParams.cqEvalChkitemScores[0].scoreResult = evaluation.getScoreLevel(this.inspectionData.scoreLevel, 'fsl')
        } else {
          this.submitParams.cqEvalChkitemScores[0].scoreResult = evaluation.getScoreLevel(this.inspectionData.score)
        }
      } else { // 高层、别墅
        for (let i = 0; i < this.submitParams.cqEvalChkitemScores.length; i++) { // 更新检查项数据
          if (this.submitParams.cqEvalChkitemScores[i].productType === this.clickObj.productType) {
            this.submitParams.cqEvalChkitemScores[i].scoreInput = this.inspectionData.score
            this.submitParams.cqEvalChkitemScores[i].scoreLevel = this.inspectionData.scoreLevel
            this.submitParams.cqEvalChkitemScores[i].subScore = this.inspectionData.reduceScore || 0
            this.submitParams.cqEvalChkitemScores[i].scoreResult = evaluation.getScoreLevel(this.inspectionData.score)
          }
        }
      }

      this.submitParams.score = this.inspectionData.score || ''
      this.submitParams.fslIsDlsyUnsuit = this.inspectionData.fslIsDlsyUnsuit
      // 判断同个工序是否选择了相同的图片和位置
      const termList2 = this.inspectionData.terms
      for (const term of termList2) {
        for (const std of term.standardList) {
          const keyMap = {}
          const unitType = std.unitType || 1
          for (const area of std.areaList) {
            // 生成位置id
            const tmpId = generateTaskRectifyTmpId(unitType, area)
            if (!tmpId) continue
            const key = `${area.fileId}_${tmpId}`
            if (keyMap[key]) return this.controlScroll(std.randomString, '同一验收标准请勿选择相同的图片和位置')
            keyMap[key] = 1
          }
        }
      }

      // 移除传 scoreItems 时不用的数据
      const terms = []
      const termList = JSON.parse(JSON.stringify(this.inspectionData.terms))
      termList.map(term => {
        term.standardList.map(std => {
          delete std.fileItems
          delete std.areaList
          delete std.areaListBackUp
        })
      })
      for (let i = 0; i < termList.length; i++) {
        if (termList[i].standardList && termList[i].standardList.length > 0) {
          terms.push(...termList[i].standardList)
        }
        const standardList = termList[i].standardList
        for (let j = 0; j < standardList.length; j++) {
          if (standardList[j].children && standardList[j].children.length > 0) {
            // const existArr = ['tjlchy', 'jzjfybys'] //  土建楼层会验 与 精装交付样板验收 已经提交过
            // const list = standardList[j].children.filter(item => !existArr.some(aItem => aItem === item.courseCode))
            terms.push(...standardList[j].children)
          }
        }
      }
      terms.forEach(item => {
        this.noCheckReset(item)
      })
      this.submitParams.scoreItems = terms

      const saveAreas = []
      const deleteAreas = []
      const scoreType = this.submitParams.chkitemCode
      this.inspectionData.terms.map(term => {
        term.standardList.map(std => {
          const areas = []
          std.areaList.map(area => {
            const { itemFileId, rectifyId, standardType, fileId, taskFileId, shortName } = area
            // 从历史记录里选的
            if (rectifyId && standardType === scoreType) return areas.push({ rectifyId, fileId, taskFileId, shortName })

            // 移除 rectifyId (不表示从历史选，不应含此参数)
            const area2 = JSON.parse(JSON.stringify(area))
            delete area2.rectifyId

            const unitType = std.unitType || 1
            const item = { projectId, itemFileId, fileId, taskFileId, unitType }
            assignAreaPosition(unitType, item, area2)
            if (item.drawArea && typeof item.drawArea === 'object') {
              try {
                item.drawArea = JSON.stringify(item.drawArea)
              } catch (error) {
                console.log(error)
              }
            }
            areas.push(item)
          })

          // 判断删除的位置
          const list2 = std.areaListBackUp || []
          if (list2.length) {
            const itemFileIds = areas.map(i => i.itemFileId).filter(i => i)
            list2.map(i => {
              if (itemFileIds.includes(i.itemFileId)) return
              deleteAreas.push(i.itemFileId)
            })
          }

          if (!areas.length) return
          const item = { standardId: std.standardId, areas }
          if (std.mrqId) item.mrqId = std.mrqId
          saveAreas.push(item)
        })
      })
      this.submitParams.saveAreas = saveAreas
      this.submitParams.deleteAreas = deleteAreas
      if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) {
        this.submitParams.gxysScore = this.inspectionData.gxysScore
        this.submitParams.ybysScore = this.inspectionData.ybysScore
        this.submitParams.daglScore = this.inspectionData.daglScore
      } else {
        delete this.submitParams.gxysScore
        delete this.submitParams.ybysScore
        delete this.submitParams.daglScore
      }

      const opts = { ...this.submitParams }
      // 管理动作加 gldzId
      opts.scoreType === SCORE_TYPE.GLDZ && (opts.gldzId = rdcScore.gldzId)

      this.loading = true
      saveItemScores(opts).then(response => {
        if (response.code === 200) {
          this.msgSuccess('抽检结果保存成功。')
          this.$emit('submitSuccess')
        }
        this.inspectionData.terms = []
        this.inspectionData.score = ''
        this.inspectionData.scoreLevel = ''
        this.show = false
      }).finally(() => {
        this.loading = false
      })
    },
    /*
    *  滚动到指定位置
    * */
    controlScroll(ref, message) {
      this.$message({
        message: message || '存在未填写标准项，若无异常可填写 0 或 选符合。',
        type: 'warning',
        duration: 5000
      })
      this.allExpand(true)
      setTimeout(() => {
        const scrollTop = this.$refs[ref][0].offsetTop - this.$refs.standardListTop.offsetHeight / 2 + 100
        this.$refs.standardListTop.scrollTop = scrollTop
      }, 500)
    },
    // 实测实量 数量改变
    scslCountChange(data) {
      if (data.checkTotal && !Number(data.checkTotal)) {
        this.$message.error('数量请输入数字！')
        data.checkTotal = null
        return
      }
      if (data.goodTotal && !Number(data.goodTotal)) {
        this.$message.error('数量请输入数字！')
        data.goodTotal = null
        return
      }
      if (data.goodTotal < 0 || data.goodTotal > 999 || data.checkTotal < 0 || data.checkTotal > 999) {
        this.$message.error('请输入在 0 ~ 999范围内数量！')
        data.goodTotal = null
        data.checkTotal = null
        return
      }
      if ((data.checkTotal || data.goodTotal) && Number(data.checkTotal) < Number(data.goodTotal)) {
        this.$message.error('合格数量不能大于实际检查！')
        data.goodTotal = null
        return
      }
      if (data.checkTotal < 1 && data.checkTotal > 0 || data.goodTotal < 1 && data.goodTotal > 0) {
        data.checkTotal = parseInt(data.checkTotal)
        data.goodTotal = parseInt(data.goodTotal)
      }
      evaluation.qualifiedScore(data)
      this.overallEvaluation()
    },
    /*
    *  按类扣分  获取数据
    * */
    getCategoryData(event, point) {
      point.badTotal = event.validTotal || null
      point.typeJson = JSON.stringify(event.categoryList)
      let ruleJson = []
      try {
        ruleJson = JSON.parse(point.ruleJson)
      } catch (e) {
        console.log(e)
      }
      console.log(point.ruleType, ruleJson)
      if (ruleJson.length > 0) {
        evaluation.categoryReduceScore(point, ruleJson)
        this.overallEvaluation()
      }
    },
    /*
    *  数量改变
    * */
    badTotalChange(data) {
      // 数据验证
      if (data.ruleType === RULE_TYPE.HGJF) {
        if (data.checkTotal && !Number(data.checkTotal)) {
          this.$message.error('数量请输入数字！')
          data.checkTotal = null
          return
        }
        if (data.goodTotal && !Number(data.goodTotal)) {
          this.$message.error('数量请输入数字！')
          data.goodTotal = null
          return
        }
        // 提醒 但不限制数据提交
        // if (data.checkTotal < data.mixCheck) {
        //   this.$message.warning('实际检查数量应 检查点要求 数量！')
        // }
        if (data.goodTotal < 0 || data.goodTotal > 999 || data.checkTotal < 0 || data.checkTotal > 999) {
          this.$message.error('请输入在 0 ~ 999范围内数量！')
          data.goodTotal = null
          data.checkTotal = null
          return
        }
        if ((data.checkTotal || data.goodTotal) && Number(data.checkTotal) < Number(data.goodTotal)) {
          this.$message.error('合格数量不能大于实际检查！')
          data.goodTotal = null
          return
        }
        if (data.checkTotal < 1 && data.checkTotal > 0 || data.goodTotal < 1 && data.goodTotal > 0) {
          data.checkTotal = parseInt(data.checkTotal)
          data.goodTotal = parseInt(data.goodTotal)
        }
      } else {
        if (data.badTotal && !Number(data.badTotal)) {
          this.$message.error('数量请输入数字！')
          data.badTotal = null
          return
        }
        if (data.badTotal < 0 || data.badTotal > 999) {
          this.$message.error('请输入在 0 ~ 999范围内数量！')
          data.badTotal = null
          return
        }
        if (data.badTotal < 1 && data.badTotal > 0) {
          data.badTotal = parseInt(data.badTotal)
        }
      }
      let ruleJson = []
      try {
        ruleJson = JSON.parse(data.ruleJson)
      } catch (e) {
        this.$alert('抽查规则json配置出错，请先正确配置抽查规则', 'JSON格式出错', {
          confirmButtonText: '确定',
          callback: action => {}
        })
        console.log(e)
      }
      console.log(data.badTotal, data.ruleType, ruleJson, RULE_TYPE)
      if (ruleJson && ruleJson instanceof Array && ruleJson.length > 0) {
        if (data.ruleType === RULE_TYPE.SJTK) { // 升级条款
          evaluation.upgradeTerms(data, ruleJson)
        } else if (data.ruleType === RULE_TYPE.HGTK) { // 合格条款 违反标准 (超过最小阈值)
          evaluation.violateStandard(data, ruleJson)
        } else if (data.ruleType === RULE_TYPE.ZJPD) { // 直接评定
          evaluation.directGrade(data, ruleJson)
        } else if (data.ruleType === RULE_TYPE.HGJF) { // 合格计分（违反扣分） goodTotal 与 checkTotal
          evaluation.qualifiedScore(data, ruleJson)
        } else if (data.ruleType === RULE_TYPE.YZKF) { // 阈值扣分 （阈值范围，扣分）
          evaluation.rangeReduceScore(data, ruleJson)
        } else if (data.ruleType === RULE_TYPE.CFKF) { // 重复扣分 （（badTotal - min) * score），扣分）
          evaluation.repetiteReduceScore(data, ruleJson)
        } else if (data.ruleType === RULE_TYPE.ZJKF) { // 直接扣分 （超过阈值 扣相同分）
          evaluation.directReduceScore(data, ruleJson)
        }
      }
      this.overallEvaluation()
    },
    /*
    *  整体评估
    * */
    overallEvaluation() {
      const terms = this.inspectionData.terms.filter(term => term.type !== 'title')
      if (this.submitParams.chkitemCode === SCORE_TYPE.FSL) { // 直接评估等级
        evaluation.fslMergeItemHandle(terms)
        const obj = evaluation.antiseepEvaluation(terms, this.antiseepRule)
        this.locationType.checkAll = obj.allNoCheck
        this.inspectionData.scoreLevel = obj.score
        if (this.inspectionData.fslIsDlsyUnsuit === 1) {
          if (this.inspectionData.score === 'A') {
            this.inspectionData.score = 'B'
          } else if (this.inspectionData.score === 'B') {
            this.inspectionData.score = 'C'
          }
        }
      } else if (this.submitParams.chkitemCode === SCORE_TYPE.ZLKGKL) { // 计算 空鼓开裂 得分
        const params = { isConstruction: this.isConstruction, productType: this.submitParams.productType }
        const obj = evaluation.calculateKgklScore(terms, params)
        this.submitParams.cqRdcZlScoreVO = obj.cqRdcZlScoreVO
        this.locationType.checkAll = obj.allNoCheck
        this.inspectionData.score = obj.score
        this.inspectionData.reduceScore = obj.reduceScore
        this.inspectionData.scoreLevel = obj.scoreLevel
        // 细项得分
        this.detailScore.indoor = obj.indoor
        this.detailScore.publicArea = obj.publicArea
        // 动态勾选
        this.getNoCheckItem()
      } else if (this.submitParams.chkitemCode === SCORE_TYPE.ZLGG) { // 计算 观感 得分
        const params = { isConstruction: this.isConstruction, productType: this.submitParams.productType }
        const obj = evaluation.calculateGgScore(terms, params)
        this.submitParams.cqRdcZlScoreVO = obj.cqRdcZlScoreVO
        this.locationType.checkAll = obj.allNoCheck
        this.inspectionData.score = obj.score
        this.inspectionData.reduceScore = obj.reduceScore
        this.inspectionData.scoreLevel = obj.scoreLevel
        // 细项得分
        this.detailScore.indoor = obj.indoor
        this.detailScore.publicArea = obj.publicArea
        if (this.isConstruction) {
          this.detailScore.outsideWall = obj.outsideWall
        }
        // 动态勾选
        this.getNoCheckItem()
      } else if (this.submitParams.chkitemCode === SCORE_TYPE.ZLSCSL) { // // 计算 实测实量 得分
        const params = { isConstruction: this.isConstruction, productType: this.submitParams.productType }
        const obj = evaluation.calculateScslScore(terms, params)
        this.submitParams.cqRdcZlScoreVO = obj.cqRdcZlScoreVO
        this.locationType.checkAll = obj.allNoCheck
        this.inspectionData.score = obj.score
        this.inspectionData.scoreLevel = obj.scoreLevel
      } else if (this.$route.query.chkitemCode === CHECK_TYPE_CODE.GLDZ) { // // 计算 管理动作 得分
        const obj = evaluation.calculateGldzAllScore(terms, this.inherit)
        this.locationType.checkAll = obj.allNoCheck
        this.inspectionData.score = obj.score
        this.inspectionData.gxysScore = obj.gxysScore
        this.inspectionData.ybysScore = obj.ybysScore
        this.inspectionData.daglScore = obj.daglScore
        this.inspectionData.scoreLevel = obj.scoreLevel
        // 动态勾选
        this.getNoCheckItem()
      } else { // 计算 其他 分数
        const obj = evaluation.calculateScore(terms)
        this.locationType.checkAll = obj.allNoCheck
        this.inspectionData.score = obj.score
        this.inspectionData.scoreLevel = obj.scoreLevel
      }
    },
    async removeArea(list, item, index) {
      const res1 = await this.$confirm('确认移除本项?', '警告', { type: 'warning' }).catch(() => false)
      if (res1 !== 'confirm') return
      list.splice(index, 1)
    },
    // 当前条款内是否有选中
    isCheckedInTerm(termIndex) {
      const terms = this.inspectionData.terms
      const stdList = terms[termIndex].standardList
      for (const std of stdList) {
        for (const area of std.areaList) {
          if (area.checked) return true
        }
      }
      return false
    },
    // 禁用/解除其他检查项的复选框
    toggleCheckboxForOtherItems(termIndex) {
      const terms = this.inspectionData.terms
      const checked = this.isCheckedInTerm(termIndex)
      this.isMultiAreas = checked
      this.currTermAreas.termIndex = termIndex
      const status = checked ? 'disabled' : ''
      const currStatus = checked ? 'show' : ''
      terms.map((term, index) => {
        term.checkboxStatus = index === termIndex ? currStatus : status
      })
    },
    resetAllCheckbox() {
      const terms = this.inspectionData.terms
      terms.map(term => {
        term.checkboxStatus = ''
        term.standardList.map(std => std.areaList.map(area => (area.checked = false)))
      })
      this.isMultiAreas = false
    },
    // 选择位置回调
    onSelectArea(data) {
      const { termIndex, unitType, list } = this.currTermAreas
      const term = this.inspectionData.terms[termIndex]

      list.map(item => {
        const { stdIndex, areaIndex, area } = item
        // position 赋值到 area
        assignAreaPosition(unitType, area, data.position)
        term.standardList[stdIndex].areaList[areaIndex] = area
      })
      // 处理多层嵌套导致页面数据不同步
      this.$set(this.inspectionData.terms, termIndex, term)
    },
    // 打开选择图片文件
    openSelectFileList(termIndex, stdIndex) {
      this.currStandard = { termIndex, stdIndex }
      const opt = {
        processType: this.checkRecordRow.processType,
        taskId: this.checkRecordRow.prjchkId,
        scoreType: this.submitParams.chkitemCode
      }
      this.$refs.SelectFileList.open(opt)
    },
    // 选择图片文件回调
    async onSelectFileList(data) {
      const rdcScore = this.checkRecordRow
      const { termIndex, stdIndex } = this.currStandard
      const list = this.inspectionData.terms[termIndex].standardList[stdIndex].areaList

      // 含有已存在的图片
      const fileIds = list.map(i => i.fileId)
      const existFile = data.find(i => fileIds.includes(i.fileId))
      if (existFile) {
        const res1 = await this.$confirm('选中的图片中含有已存在的图片，是否继续添加？', '警告', { type: 'warning' }).catch(() => false)
        if (res1 !== 'confirm') return
      }

      data.map(item => {
        list.push({
          checked: false,
          projectId: rdcScore.projectId,
          taskFileId: item.taskFileId,
          fileId: item.fileId,
          url: item.url
        })
      })

      this.msgInfo(`已添加${data.length}个文件`)
    },
    // 关闭 drawer 前动作处理
    handleClose(done) {
      this.$confirm('确认关闭评估表单？')
        .then(_ => {
          this.inspectionData.terms = []
          this.inspectionData.score = ''
          this.inspectionData.scoreLevel = ''
          this.collapseValue = []
          done()
        })
        .catch(_ => {})
    }
  }
}
</script>

<style scoped lang='scss'>
  $dlsyColor: #F56C6C;
  .custom-radio {
    /deep/.el-radio__label {
      white-space: pre-wrap;
      display: inline-flex;
    }
    /deep/.el-radio {
      margin-bottom: 6px;
    }
  }
  .drawer-content {
    height: 100%;
    .drawer-content-title {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 20px;
      border-bottom: 1px #DCDFE6 solid;
      .location-type-all {

      }
    }
    .drawer-content-data{
      padding: 0 20px 20px;
      height: calc(100% - 120px);
      overflow-y: auto;
      position: relative;
      .base-terms-title {
        background-color: #0000001a;
        padding: 10px 20px;
        font-size: 18px;
        box-sizing: border-box;
        font-weight: 700;
        margin: 30px 0 0 -30px;
      }
      .base-terms-content {
        min-width: 700px;
        padding-left: 30px;
        .base-terms-item {
          .check-type {
            color: #333;
            font-size: 16px;
            box-sizing: border-box;
            font-weight: 700;
            .parent-table-name {
              /*font-weight: normal;
              font-size: 13px;
              margin-left: 10px;
              color: #909399*/
            }
            .location-type {
              margin-left: 20px;
            }
          }
          .point-content {
            padding: 16px;
            background-color: #f5f9ff;
            border-radius: 5px;
            margin-top: 10px;
            border: 1px #cbdfff solid;
            .point-descr {
              font-size: 14px;
              box-sizing: border-box;
              font-weight: 700;
              margin: 10px 0 20px 0;
              display: flex;
              align-items: center;
              justify-content: space-between;
              .rule-content {
                cursor: pointer;
                font-size: 16px;
                color: #333333;
                margin-left: 10px;
                &:hover {
                  color: #409EFF;
                }
              }
              .no-check {
                margin-right: 20px;
              }
            }
            .operater-condition {
              margin-bottom: 16px;
            }
            .input-width {
              width: 230px;
            }
            .data-row {
              position: relative;
              .operater-first {
                display: inline-block;
                min-width: 300px;
              }
              .remain-desc {
                font-size: 12px;
                color: #ff3e4c;
                margin-top: 6px;
              }
              .violate-standard {
                margin-left: 20px;
              }
            }
          }
          .cannot-check {
            background-color: #fdfdfd;
            border: 1px #dde5ff solid;
            .cannot-check-item {
              opacity: 0.4;
            }
          }
        }
      }
    }
    .evaluation-level {
      color: #333;
      font-size: 18px;
      box-sizing: border-box;
      font-weight: 700;
      .dlsy-unsuit {
        margin-left: 80px;
      }
      .dlsy-unsuit/deep/.el-checkbox__input.is-checked + .el-checkbox__label {
        color: $dlsyColor;
      }
      .dlsy-unsuit/deep/.el-checkbox__input.is-checked .el-checkbox__inner,
      .dlsy-unsuit/deep/.el-checkbox__input.is-indeterminate .el-checkbox__inner {
        border-color: $dlsyColor !important;
        background-color: $dlsyColor !important;
      }
      .reduce-score {
        margin-left: 30px;
        font-size: 15px;
        color: rgb(255, 62, 76);
      }
      .detail-score {
        font-size: 14px;
        font-weight: normal;
        .score-item {
          margin-left: 30px;
          .score {
            font-weight: 700;
            font-size: 16px;
          }
        }
      }
    }
    .evaluation-desc {
      font-size: 12px;
      color: #909399;
      margin-top: 6px;
    }
    .button-operate {
      border-top: 1px #DCDFE6 solid;
      padding: 10px 30px 0;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .level-desc {
        display: flex;
        flex-direction: column;
      }
    }
    .danger {
      color: rgb(255, 62, 76);
    }
  }

// 图片位置列表
.vos-area-list {
  display: flex;
  flex-wrap: wrap;
  .item {
    position: relative;
    width: 64px;
    margin: 10px 10px 0 0;
    color: #606266;
    &:hover {
      .btn-del {
        display: block;
      }
      .area-checkbox {
        display: inline-block;
      }
    }
  }
  .btn-del {
    position: absolute;
    top: -5px;
    right: -5px;
    z-index: 1;
    display: none;
    background-color: white;
    border-radius: 50%;
    cursor: pointer;
    &:hover {
      color: #409eff;
    }
  }
  .img {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    cursor: pointer;
  }
  .area-name {
    height: 32px;
    font-size: 12px;
    line-height: 16px;
    &:hover {
      color: #409eff;
    }
  }
  .pointer {
    cursor: pointer;
  }
  .area-checkbox {
    margin-right: 2px;
    display: none;
    &.checked {
      display: inline-block;
    }
  }
  .area-select-img {
    width: 66px;
    height: 66px;
    line-height: 72px;
    text-align: center;
  }
}
.checkbox-disabled {
  pointer-events: none;
  opacity: 0.8;
}
.checkbox-show .area-checkbox {
  display: inline-block;
}
</style>
